package cn.db101.jcc.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zooy
 * @create 2024-06-02 2:13
 * @description
 */
@MapperScan("cn.db101.jcc.mapper")
@Configuration
@EnableConfigurationProperties(JccPropertiesConfig.class)
public class JccConfig implements WebMvcConfigurer {


    @Bean
    public WxMaService wxMaService(JccPropertiesConfig jccPropertiesConfig) {

        WxMaDefaultConfigImpl wxMaDefaultConfig = new WxMaDefaultConfigImpl();
        wxMaDefaultConfig.setAppid(jccPropertiesConfig.getAppId());
        wxMaDefaultConfig.setSecret(jccPropertiesConfig.getAppSecret());
        wxMaDefaultConfig.setMsgDataFormat("JSON");

        WxMaService wxMaService = new WxMaServiceImpl();
        wxMaService.setWxMaConfig(wxMaDefaultConfig);

        return wxMaService;

    }

}
